pltnts <- list.files("~/R/terni/rds", pattern = "^[M-Z]", full.names = TRUE) 

map(pltnts, \(pltnt) {
  inquinante <- tools::file_path_sans_ext(basename(pltnt))
  
  cat("\n## ", inquinante, "\n\n")

  df <- read_csv("~/R/terni/data/dataframes/df_finale.csv", show_col_types = FALSE)
  index <- grep(inquinante, names(df))
  names(df)[index] <- "value"

  rds <- readRDS(pltnt)
  mod <- getModel(names(rds), df)
  
  gamtabs(mod, type = "HTML")
  cat("\n\n")
    
  cat("R²:", summary(mod)$r.sq %>% round(3) )
cat("\n\n")
  # stargazer(mod, type="text" )

  appraise(mod) %>% print()
  draw(mod) %>% print()
  
  rm(mod)
  cat("\n\n")
})

Mg_i

stringa modello: gam(log(value) ~ s(nirradiance_IQR) + s(pblmin_median, k=3) + s(sp_IQR) + s(v10m_min) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) 1.3775 0.0049 283.4954 < 0.0001
B. smooth terms edf Ref.df F-value p-value
s(nirradiance_IQR) 2.4391 2.8824 12.5031 < 0.0001
s(pblmin_median) 1.0000 1.0000 23.8863 < 0.0001
s(sp_IQR) 1.0001 1.0001 132.3558 < 0.0001
s(v10m_min) 1.0000 1.0000 6.7063 0.0101

R²: 0.425

Mg_s

stringa modello: gam(log(value) ~ s(pbl00_max) + s(scrapyard) + s(wspeed_max_mean) + s(s3_sup_200) + s(s6_sup_200) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) 1.4034 0.0042 332.7256 < 0.0001
B. smooth terms edf Ref.df F-value p-value
s(pbl00_max) 4.8392 5.4881 22.2652 < 0.0001
s(scrapyard) 1.4159 1.7132 24.7618 < 0.0001
s(wspeed_max_mean) 2.7679 3.1948 6.2116 0.0003
s(s3_sup_200) 1.9556 2.3266 3.4066 0.0276
s(s6_sup_200) 1.0001 1.0002 6.0819 0.0143

R²: 0.509

Mn_i

stringa modello: gam(log(value) ~ s(s3_sup_200) + s(wdir_IQR) + s(nirradiance_max) + s(cold_area) + s(pblmin_median, k=3) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) 0.7850 0.0082 95.3319 < 0.0001
B. smooth terms edf Ref.df F-value p-value
s(s3_sup_200) 7.6200 7.7565 19.5202 < 0.0001
s(wdir_IQR) 1.0000 1.0000 60.7915 < 0.0001
s(nirradiance_max) 1.0000 1.0000 29.9658 < 0.0001
s(cold_area) 7.4337 8.1583 5.4911 < 0.0001
s(pblmin_median) 1.0000 1.0000 5.7412 0.0173

R²: 0.653

Mn_s

stringa modello: gam(log(value) ~ s(pbl12_mean) + s(scrapyard) + s(nirradiance_IQR) + s(wspeed_max) + s(s7_sup_200, k=3) + s(s6_sup_200) + s(cold_area) + s(pwspeed_max) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) 0.5601 0.0114 49.0079 < 0.0001
B. smooth terms edf Ref.df F-value p-value
s(pbl12_mean) 1.0000 1.0001 100.1215 < 0.0001
s(scrapyard) 1.0000 1.0000 44.9631 < 0.0001
s(nirradiance_IQR) 2.3936 2.7712 67.2165 < 0.0001
s(wspeed_max) 0.9928 1.2275 1.8230 0.2093
s(s7_sup_200) 1.0000 1.0000 6.0225 0.0148
s(s6_sup_200) 1.1998 1.3712 9.0031 0.0031
s(cold_area) 1.0000 1.0000 13.4237 0.0003
s(pwspeed_max) 1.9928 2.2275 2.2804 0.1033

R²: 0.705

Mo_i

stringa modello: gam(log(value) ~ s(pblmax_min) + s(cold_area) + s(s1_sup_200, k=7) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -0.2418 0.0974 -2.4819 0.0137
B. smooth terms edf Ref.df F-value p-value
s(pblmax_min) 7.8757 8.3728 22.1125 < 0.0001
s(cold_area) 2.8465 3.5748 26.8501 < 0.0001
s(s1_sup_200) 1.7710 1.9837 5.6332 0.0028

R²: 0.668

Mo_s

stringa modello: gam(log(value) ~ s(cold_area) + s(nirradiance_mean) + s(s3_sup_200) + s(pblmin_median, k=3) + s(m_dis_ferr) + s(pbl00_mean) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) 0.4577 0.0168 27.2783 < 0.0001
B. smooth terms edf Ref.df F-value p-value
s(cold_area) 3.5956 4.3740 34.6549 < 0.0001
s(nirradiance_mean) 2.6442 3.2531 33.3174 < 0.0001
s(s3_sup_200) 7.5440 7.8310 14.9215 < 0.0001
s(pblmin_median) 1.0000 1.0000 27.9580 < 0.0001
s(m_dis_ferr) 1.0001 1.0002 11.5412 0.0008
s(pbl00_mean) 1.0000 1.0000 9.5925 0.0022

R²: 0.755

Na_i

stringa modello: gam(log(value) ~ s(pwspeed_min, k=7) + s(v10m_mean) + s(tmax2m_IQR) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) 1.7114 0.0048 360.1878 < 0.0001
B. smooth terms edf Ref.df F-value p-value
s(pwspeed_min) 1.0000 1.0001 61.0800 < 0.0001
s(v10m_mean) 1.0000 1.0000 18.3960 < 0.0001
s(tmax2m_IQR) 1.0000 1.0000 8.6452 0.0036

R²: 0.203

Na_s

stringa modello: gam(log(value) ~ s(u10m_IQR) + s(s7_sup_200, k=3) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) 1.7578 0.0035 505.0096 < 0.0001
B. smooth terms edf Ref.df F-value p-value
s(u10m_IQR) 8.0000 8.0000 39.9308 < 0.0001
s(s7_sup_200) 1.8868 1.9872 5.6379 0.0044

R²: 0.562

Nb_i

stringa modello: gam(log(value) ~ s(rh_min) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -23.4201 969820731.2887 -0.0000 1.0000
B. smooth terms edf Ref.df F-value p-value
s(rh_min) 1.0000 1.0000 0.0000 1.0000

R²: -0.004

Nb_s

stringa modello: gam(log(value) ~ s(v10m_min) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -22.6778 916551596.4583 -0.0000 1.0000
B. smooth terms edf Ref.df F-value p-value
s(v10m_min) 1.0000 1.0000 0.0000 1.0000

R²: -0.004

Ni_i

stringa modello: gam(log(value) ~ s(cold_area) + s(wdir_IQR) + s(s6_sup_200) + s(s1_sup_200, k=7) + s(wdir_median) + s(t2m_IQR) + s(sp_mean) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) 0.8086 0.0120 67.2528 < 0.0001
B. smooth terms edf Ref.df F-value p-value
s(cold_area) 4.7186 5.5927 57.8875 < 0.0001
s(wdir_IQR) 1.0000 1.0000 47.3159 < 0.0001
s(s6_sup_200) 6.9075 7.7226 6.2336 < 0.0001
s(s1_sup_200) 1.3748 1.5519 4.1753 0.0135
s(wdir_median) 1.0000 1.0000 29.2577 < 0.0001
s(t2m_IQR) 1.0000 1.0000 10.7289 0.0012
s(sp_mean) 1.0000 1.0000 7.1496 0.0080

R²: 0.722

Ni_s

stringa modello: gam(log(value) ~ s(m_dis_ferr) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -2171.6198 822.9713 -2.6388 0.0088
B. smooth terms edf Ref.df F-value p-value
s(m_dis_ferr) 1.0000 1.0000 6.9647 0.0088

R²: 0.231

Pb_i

stringa modello: gam(log(value) ~ s(nirradiance_mean) + s(s3_sup_200) + s(wspeed_IQR) + s(wspeed_max_max) + s(wspeed_max_min) + s(wdir_IQR) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) 0.3775 0.0140 26.9697 < 0.0001
B. smooth terms edf Ref.df F-value p-value
s(nirradiance_mean) 1.0000 1.0000 32.1711 < 0.0001
s(s3_sup_200) 7.4182 7.8474 28.0831 < 0.0001
s(wspeed_IQR) 1.0000 1.0000 0.2321 0.6304
s(wspeed_max_max) 2.3873 2.8503 6.3126 0.0006
s(wspeed_max_min) 1.0000 1.0000 12.3599 0.0005
s(wdir_IQR) 1.0000 1.0000 6.7340 0.0100

R²: 0.673

Pb_s

stringa modello: gam(log(value) ~ s(sp_min) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -22.7611 2017.3248 -0.0113 0.9910
B. smooth terms edf Ref.df F-value p-value
s(sp_min) 1.0000 1.0001 0.0005 0.9891

R²: 0.237

PM10

stringa modello: gam(log(value) ~ s(v10m_min) + s(pwspeed_IQR) + s(v10m_median, k=9) + s(pop_200) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) 1.2172 0.0039 314.5843 < 0.0001
B. smooth terms edf Ref.df F-value p-value
s(v10m_min) 2.0134 2.3286 21.4008 < 0.0001
s(pwspeed_IQR) 3.9684 4.4831 68.1847 < 0.0001
s(v10m_median) 1.0001 1.0002 24.7028 < 0.0001
s(pop_200) 1.0001 1.0001 6.1866 0.0135

R²: 0.754

Rb_i

stringa modello: gam(log(value) ~ s(pblmin_IQR, k=9) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -23.8260 713180328.4144 -0.0000 1.0000
B. smooth terms edf Ref.df F-value p-value
s(pblmin_IQR) 1.0000 1.0000 0.0000 1.0000

R²: -0.004

Rb_s

stringa modello: gam(log(value) ~ s(tmax2m_mean) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -9.6249 9.3176 -1.0330 0.3025
B. smooth terms edf Ref.df F-value p-value
s(tmax2m_mean) 1.2578 1.4561 0.8830 0.2305

R²: 0.323

Sb_i

stringa modello: gam(log(value) ~ s(rh_max) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -131.5374 349025.3924 -0.0004 0.9997
B. smooth terms edf Ref.df F-value p-value
s(rh_max) 1.0001 1.0002 0.0001 0.9955

R²: 0.124

Sb_s

stringa modello: gam(log(value) ~ s(tmin2m_IQR) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -24.6092 1429869567.4169 -0.0000 1.0000
B. smooth terms edf Ref.df F-value p-value
s(tmin2m_IQR) 1.0000 1.0000 0.0000 1.0000

R²: -0.004

Sn_i

stringa modello: gam(log(value) ~ s(pbl12_mean) + s(hot_area) + s(s4_sup_200) + s(s8_sup_200) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -0.3424 0.0494 -6.9266 < 0.0001
B. smooth terms edf Ref.df F-value p-value
s(pbl12_mean) 1.0000 1.0000 332.2339 < 0.0001
s(hot_area) 2.1122 2.6346 19.1946 < 0.0001
s(s4_sup_200) 1.0001 1.0001 7.2134 0.0077
s(s8_sup_200) 1.6335 2.0390 5.9573 0.0029

R²: 0.779

Sn_s

stringa modello: gam(log(value) ~ s(pblmin_median, k=3) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -23.0719 467030630.5307 -0.0000 1.0000
B. smooth terms edf Ref.df F-value p-value
s(pblmin_median) 1.0000 1.0000 0.0000 1.0000

R²: -0.004

Sr_i

stringa modello: gam(log(value) ~ s(tp_IQR) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -2.9084 5.5494 -0.5241 0.6006
B. smooth terms edf Ref.df F-value p-value
s(tp_IQR) 7.0532 7.1164 3.4669 0.0007

R²: 0.441

Sr_s

stringa modello: gam(log(value) ~ s(v10m_median, k=9) + s(imp_200) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -1.6333 102.5148 -0.0159 0.9873
B. smooth terms edf Ref.df F-value p-value
s(v10m_median) 7.0000 7.0001 23.6825 < 0.0001
s(imp_200) 1.0000 1.0000 6.9530 0.0089

R²: 0.61

Ti_i

stringa modello: gam(log(value) ~ s(rh_max) + s(pop_200) + s(pblmin_IQR, k=9) + s(s3_sup_200) + s(s4_sup_200) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) 0.4315 0.0140 30.7584 < 0.0001
B. smooth terms edf Ref.df F-value p-value
s(rh_max) 3.1428 3.8193 39.0249 < 0.0001
s(pop_200) 6.4832 7.1177 8.2150 < 0.0001
s(pblmin_IQR) 1.0001 1.0001 42.6792 < 0.0001
s(s3_sup_200) 3.8167 4.1252 4.0033 0.0017
s(s4_sup_200) 1.0001 1.0001 17.1647 < 0.0001

R²: 0.528

Ti_s

stringa modello: gam(log(value) ~ s(u10m_mean) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -23.7015 1110537246.7412 -0.0000 1.0000
B. smooth terms edf Ref.df F-value p-value
s(u10m_mean) 1.0000 1.0000 0.0000 1.0000

R²: -0.004

Tl_i

stringa modello: gam(log(value) ~ s(s5_sup_200, k=9) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -22.8890 910243221.4849 -0.0000 1.0000
B. smooth terms edf Ref.df F-value p-value
s(s5_sup_200) 1.0000 1.0000 0.0000 1.0000

R²: -0.004

Tl_s

stringa modello: gam(log(value) ~ s(s3_sup_200) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -22.5587 419614258.4032 -0.0000 1.0000
B. smooth terms edf Ref.df F-value p-value
s(s3_sup_200) 1.0000 1.0000 0.0000 1.0000

R²: -0.004

U_i

stringa modello: gam(log(value) ~ s(kndvi) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -22.2572 573815329.4478 -0.0000 1.0000
B. smooth terms edf Ref.df F-value p-value
s(kndvi) 1.0000 1.0000 0.0000 1.0000

R²: -0.004

U_s

stringa modello: gam(log(value) ~ s(tp_median, k=3) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -22.2573 670082786.1382 -0.0000 1.0000
B. smooth terms edf Ref.df F-value p-value
s(tp_median) 1.0000 1.0000 0.0000 1.0000

R²: -0.004

V_i

stringa modello: gam(log(value) ~ s(tmin2m_IQR) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -24.8338 1374423269.9621 -0.0000 1.0000
B. smooth terms edf Ref.df F-value p-value
s(tmin2m_IQR) 1.0000 1.0000 0.0000 1.0000

R²: -0.004

V_s

stringa modello: gam(log(value) ~ s(t2m_min) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
## Warning in newton(lsp = lsp, X = G$X, y = G$y, Eb = G$Eb, UrS = G$UrS, L = G$L,
## : Adattamento terminato con errore di passo: controllare attentamente i
## risultati
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -42.5595 68.3869 -0.6223 0.5342
B. smooth terms edf Ref.df F-value p-value
s(t2m_min) 1.0000 1.0000 0.3700 0.5435

R²: 0.131

W_i

stringa modello: gam(log(value) ~ s(u10m_median, k=9) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -22.5540 418208955.1281 -0.0000 1.0000
B. smooth terms edf Ref.df F-value p-value
s(u10m_median) 1.0000 1.0000 0.0000 1.0000

R²: -0.004

W_s

stringa modello: gam(log(value) ~ s(u10m_median, k=9) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -22.7686 503187178.7599 -0.0000 1.0000
B. smooth terms edf Ref.df F-value p-value
s(u10m_median) 1.0000 1.0000 0.0000 1.0000

R²: -0.004

Zn_i

stringa modello: gam(log(value) ~ s(wdir_mean) + s(nirradiance_max) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) 1.2598 0.0071 176.2748 < 0.0001
B. smooth terms edf Ref.df F-value p-value
s(wdir_mean) 6.8044 7.6989 22.9497 < 0.0001
s(nirradiance_max) 1.0001 1.0002 3.0862 0.0801

R²: 0.41

Zn_s

stringa modello: gam(log(value) ~ s(nirradiance_mean) + s(scrapyard) + s(v10m_IQR) , gamma=1.4, family=gaussian(link=log), data = df)
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) 1.1164 0.0075 148.6038 < 0.0001
B. smooth terms edf Ref.df F-value p-value
s(nirradiance_mean) 4.9428 5.4388 51.9507 < 0.0001
s(scrapyard) 3.2254 4.0040 9.9808 < 0.0001
s(v10m_IQR) 3.0812 3.6322 26.1013 < 0.0001

R²: 0.754

Zr_i

stringa modello: gam(log(value) ~ s(sp_median) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -24.5748 935817661.1736 -0.0000 1.0000
B. smooth terms edf Ref.df F-value p-value
s(sp_median) 1.0000 1.0000 0.0000 1.0000

R²: -0.004

Zr_s

stringa modello: gam(log(value) ~ s(pbl00_median, k=6) , gamma=1.4, family=gaussian(link=log), data = df)

## Warning in log(mu): Si è prodotto un NaN
A. parametric coefficients Estimate Std. Error t-value p-value
(Intercept) -22.7011 677221618.5782 -0.0000 1.0000
B. smooth terms edf Ref.df F-value p-value
s(pbl00_median) 1.0000 1.0000 0.0000 1.0000

R²: -0.004

[[1]] NULL

[[2]] NULL

[[3]] NULL

[[4]] NULL

[[5]] NULL

[[6]] NULL

[[7]] NULL

[[8]] NULL

[[9]] NULL

[[10]] NULL

[[11]] NULL

[[12]] NULL

[[13]] NULL

[[14]] NULL

[[15]] NULL

[[16]] NULL

[[17]] NULL

[[18]] NULL

[[19]] NULL

[[20]] NULL

[[21]] NULL

[[22]] NULL

[[23]] NULL

[[24]] NULL

[[25]] NULL

[[26]] NULL

[[27]] NULL

[[28]] NULL

[[29]] NULL

[[30]] NULL

[[31]] NULL

[[32]] NULL

[[33]] NULL

[[34]] NULL

[[35]] NULL

[[36]] NULL

[[37]] NULL